<?php
include("connect.php");
if (isset($_POST['submit'])) {
    if (!$_POST['desc']) {
        die("Description is a required field.");
    }
    $desc = $_POST['desc'];
    $shard = "false";
    if ($_POST['shard']) {
        $shard = $_POST['shard'];
    }
    $est = 0;
    if ($_POST['est']) {
        $est = $_POST['est'];
    }
    
    $ins = "insert into project(description, shared, estimate) values ('" .
            $desc . "', '" . $shard . "', '" . $est . "')";

    $created = mysql_query($ins) or die(mysql_error());
    header("Location: index.php");
} else {
    include("header.php");
?>

<form action="<?php echo $_SERVER['PHP_SELF']?>" method=post>
<table width="75%" align=center>
<tr>
<th colspan=3 align=center>
New Project
</th>
</tr>

<tr><td colspan=3 align=center>
<a href=logout.php>Logout</a>
</td></tr>
<tr>
    <td>Project Description</td>
    <td>Shared Prorject</td>
    <td>Estimated Time</td>
</tr>
<tr>
    <td align><input type=text name=desc></td>
    <td align=right><input type=checkbox name=shard></td>
    <td align><input type=text name=est></td>
</tr>
<tr>
    <td colspan=3 align=right><input type=submit name=submit value=Create></td>
</tr>
</table>
</form>

<?
}

include "footer.php";
?>

